import React, {Component, Suspense} from 'react';
import {
  Router,
  Switch,
  Route,
  Redirect
} from "react-router-dom";
// import Layout from "pages/Layout";
// import Login from "pages/Login";
import AuthRoute from "components/AuthRoute";
import NoMatch from 'pages/NoMatch/index'
import history from "./utils/history";

const Login = React.lazy(() => import('./pages/Login'))
const Layout = React.lazy(() => import('./pages/Layout'))
console.log(Login)


class App extends Component {
  render() {
    return (
      <Router history={history}>
        <Suspense fallback={<div>loading....</div>}>
          <Switch>
            {/*  重定向*/}
            {/*一级路由*/}
            <Redirect from={'/'} to={'/home'} exact/>
            <AuthRoute path={'/home'} component={Layout}/>
            <Route path={'/login'} component={Login}/>
            {/*  配置一个404的路由*/}
            <Route path={'*'} component={NoMatch}/>
          </Switch>
        </Suspense>
      </Router>
    );
  }
}

export default App;
